<!-- 发票作废 -->
<template>
	<a-modal v-bind="options" title="重新推送">
		<p v-if="props?.invoiceType === 2">重新推送该冲红申请至终端开票,确定要重新推送吗?</p>
		<p v-if="props?.invoiceType === 1">重新推送该开票申请至终端开票,确定要重新推送吗?</p>
		<template #footer>
			<a-button @click="emits('close')">取消</a-button>
			<a-button type="primary" :loading="loading" @click="sure">确定</a-button>
		</template>
	</a-modal>
</template>

<script setup lang="ts">
	import {reactive, ref, toRef} from 'vue'
	import {rePushAgain} from '@/api/invoicing-history'
	import {message} from 'ant-design-vue'

	const props = defineProps<{
		id?: string
		invoiceInfoId?: string
		visible?: boolean
		invoiceType?: string | number
	}>()
	const emits = defineEmits(['update:visible', 'close', 'success'])

	const loading = ref(false)

	const options = reactive({
		width: 520,
		centered: true,
		maskClosable: false,
		destroyOnClose: true,
		confirmLoading: true,
		visible: toRef(props, 'visible'),
		onCancel() {
			// emits('close')
			emits('update:visible', false)
			setTimeout(() => emits('close'), 100)
		}
	})

	const sure = () => {
		rePushAgain(props?.id as string).then(() => {
			message.success('重新推送成功')
			emits('success')
			emits('update:visible', false)
			setTimeout(() => emits('close'), 100)
		})
	}
</script>

<style scoped></style>
